package me.xplabs.view 
{
	import flash.display.Bitmap;
	import flash.display.DisplayObjectContainer;
	import flash.events.MouseEvent;
	import me.xplabs.constant.SceneType;
	import me.xplabs.Globals;
	import me.xplabs.msg.NotificationFight;
	import me.xplabs.msg.NotificationName;
	import me.xplabs.ui.baseui.Button;
	import me.xplabs.ui.BaseView;
	import me.xplabs.ui.UICompent;
	
	/**
	 * http://www.xplabs.me/
	 * @author xiaohan
	 */
	public class GameMenuView extends BaseView 
	{
		private var _backGround:Bitmap;
		private var _resumeBtn:Button;
		private var _quitBtn:Button;
		private var _restartBtn:Button;
		public function GameMenuView(pfather:DisplayObjectContainer) 
		{
			super(pfather);
			
		}
		override protected function init():void 
		{
			super.init();
			
			_backGround = new Bitmap();
			_backGround.bitmapData = Globals.lib.getResObj(Globals.domain.texture + 28);
			addChild(_backGround);
			
			_resumeBtn = Globals.ui.button("", 14);
			_resumeBtn.x = 238;
			_resumeBtn.y = 197;
			addChild(_resumeBtn);
			_resumeBtn.callback = clickResumeHandler;
			
			_quitBtn = Globals.ui.button("", 7);
			_quitBtn.x = 248;
			_quitBtn.y = 275;
			addChild(_quitBtn);
			_quitBtn.callback = clickQuitHandler;
			
			_restartBtn = Globals.ui.button("", 9);
			_restartBtn.x = 239;
			_restartBtn.y = 337;
			addChild(_restartBtn);
			_restartBtn.callback = clickRestartHandler;
			
			pw = _container.width;
			ph = _container.height;
			
			maskEnabled = true;
			//UICompent.addListener(_resumeBtn);
			//UICompent.addListener(_quitBtn);
			//UICompent.addListener(_restartBtn);
		}
		
		private function clickRestartHandler(e:MouseEvent):void 
		{
			sendMsg(NotificationName.HIDE_GAME_MENU);
			sendMsg(NotificationName.TRY_ANGIN_GAME);
		}
		
		private function clickQuitHandler(e:MouseEvent):void 
		{
			sendMsg(NotificationName.HIDE_GAME_MENU);
			sendMsg(NotificationName.CHANGE_SCENE, SceneType.SELECT_SCENE);
		}
		
		private function clickResumeHandler(e:MouseEvent):void 
		{
			sendMsg(NotificationName.HIDE_GAME_MENU);
			sendMsg(NotificationName.FIGHT_MAP_MANAGER, null, NotificationFight.REGAIN_GAME);
		}
		
	}

}